package com.deman.framework.rpc.netty.handler;

import com.deman.framework.rpc.netty.ClientHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.serialization.ClassResolvers;
import io.netty.handler.codec.serialization.ObjectDecoder;
import io.netty.handler.codec.serialization.ObjectEncoder;

public class ClientInitChannel extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ch.pipeline().addLast(new ObjectDecoder(ClassResolvers.softCachingResolver(System.class.getClassLoader())));
        ch.pipeline().addLast(new ObjectEncoder());
        ch.pipeline().addLast(new ClientHandler());
    }
}
